#!/bin/sh
#
# System RC script invoking.
# (c) dangbinghoo@gmail.com 2011
#     playpenguin.org
#

. /etc/conf.d/runlevels.conf

# start rc service 
# $1 : service (service name begain with '-' will skip)
# $2 : action (start, stop)
rc_service()
{
	srv=$1
	act=$2

	if [[ `echo $srv | grep "^-" ` != "" ]];then
		srv=`echo $srv | sed 's/^-//'`
		# skip this service
	else 
		# will act
		$srv $act
	fi
}

#
# main
#

case "$1" in
	start)
		/etc/init.d/boot start	
		;;
	default)
        for rcs in `echo "${level_default}"`;do
            	rc_service /etc/init.d/$rcs start
        done
		;;
	reboot)
        for rcs in `echo "${level_reboot}"`;do
            	rc_service /etc/init.d/$rcs stop
        done
		;;
	shutdown)
        for rcs in `echo "${level_shutdown}"`;do
            	rc_service /etc/init.d/$rcs stop
        done
		;; 
	*)
		echo "ERROR: unknown rc init level!"
		exit 1
		;;
esac

